package cn.xshi.oauth.service.impl;

import cn.xshi.oauth.dao.OauthAccountTypeDao;
import cn.xshi.oauth.form.OauthAccountTypeForm;
import cn.xshi.oauth.model.OauthAccountType;
import cn.xshi.oauth.service.OauthAccountTypeService;
import cn.xshi.common.base.BaseService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
 * @Desc 账号类型
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class OauthAccountTypeServiceImpl extends BaseService implements OauthAccountTypeService {

    @Resource
    OauthAccountTypeDao oauthAccountTypeDao;

    /**
     * 分页
     * @param oauthAccountTypeForm
     * @return
     */
    public List<OauthAccountType> getOauthAccountTypeList(OauthAccountTypeForm oauthAccountTypeForm){
        return oauthAccountTypeDao.getOauthAccountTypeList(oauthAccountTypeForm);
    }
    /**
     * 查询对象
     * @param id
     * @return
     */
    public OauthAccountType getOauthAccountTypeById(String id){
        return oauthAccountTypeDao.getOauthAccountTypeById(id);
    }

    /**
     * 添加
     * @param oauthAccountType
     * @return
     */
    public int addOauthAccountType(OauthAccountType oauthAccountType){
        oauthAccountType.setCreateId(getCurrentAccountId());
        oauthAccountType.setCreateTime(getDate());
        return oauthAccountTypeDao.addOauthAccountType(oauthAccountType);
    }

    /**
     * 修改（根据动态条件）
     * @param oauthAccountType
     * @return
     */
    public int updateOauthAccountType(OauthAccountType oauthAccountType){
        oauthAccountType.setUpdateId(getCurrentAccountId());
        oauthAccountType.setUpdateTime(getDate());
        return oauthAccountTypeDao.updateOauthAccountType(oauthAccountType);
    }

    /**
     * 删除类型
     * @param oauthAccountType
     * @return
     */
    public int delAccountType(OauthAccountType oauthAccountType){
        return oauthAccountTypeDao.delAccountType(oauthAccountType);
    }

    /**
     * 根据角色获取当前系统中隶属于其账户类型
     * @param condition
     * @return
     */
    public List<OauthAccountType> getAccountTypeListByRoleId(Map<String,Object> condition){
        return oauthAccountTypeDao.getAccountTypeListByRoleId(condition);
    }

    /**
     * 根据账号类型及子系统获取有多少个
     * @param condition
     * @return
     */
    public int getAccountTypeInSysMode(Map<String,Object> condition){
        return oauthAccountTypeDao.getAccountTypeInSysMode(condition);
    }

    /**
     * 根据唯一键查找对象
     * @param atKey
     * @return
     */
    public OauthAccountType getAccountTypeByAtKey(String atKey){
        return oauthAccountTypeDao.getAccountTypeByAtKey(atKey);
    }
}
